package com.example.demo.Repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.example.demo.Entity.Employee;

/**
 * @version: V0.3
 * @author: 郑皓杰 吴嘉鑫
 * @className: IEmployeeRepository
 * @packageName: com.example.demo.Repository
 * @description: 这是员工实体数据链接的接口
 * @data: 2021-07-14
 **/

public interface IEmployeeRepository extends JpaRepository<Employee , Integer>{

	public Employee findBytelephone(String telephone);
	public Employee findByUsername(String username);
	public List<Employee> findByRealname(String realname);
	public List<Employee> findByCompanyID(Integer companyID);
	public Employee findByEmpid(Integer empid);
	public Employee findByemail(String email);
	
	@Query(value = "select empid from employee b  where b.telephone=?1", nativeQuery = true)
    public Integer findempidBytel(String tel);
	
	@Query(value = "select empid from employee b  where b.username=?1", nativeQuery = true)
    public Integer findempidByUsername(String username);
	
	public List<Employee> findByEmpidIn(List<Integer> empid);
	
	public Page<Employee> findByEmpidIn(List<Integer> list,Pageable pageable);
	
	public Page<Employee> findByRealname(String realname,Pageable pageable);
	
	@Query(value = "select b from employee b  where b.isFree==?1", nativeQuery = true)
	public List<Employee> findByState(Boolean state);
	
}